SHELL := /bin/bash
.PHONY: all product clean_proto build_proto build_all_code

ERL_LIBS="_build/default/lib"

GAME_APP_PATH="apps/game"
YAML_PATH="proto/yaml"
PROTO_OUT_PATH="proto/proto"
PROTO_CMD_OUT_PATH="$(GAME_APP_PATH)/src/proto/proto_cmd"
PROTO_VERSION="3"

all: build_proto build_all_code

product: get_deps build_deps build_proto build_all_code


get_deps:
	./rebar3 get-deps

build_deps:
	./rebar3 compile -d


build_all_code:
	./rebar3 compile

clean_proto:
	rm -rf $(PROTO_OUT_PATH)/*
	rm -rf $(PROTO_CMD_OUT_PATH)/*

build_proto: clean_proto
	erl -noinput -env ERL_LIBS $(ERL_LIBS) -eval "yaml2proto:build(\"$(YAML_PATH)\", \"$(PROTO_OUT_PATH)\", \"$(PROTO_CMD_OUT_PATH)\", \"$(PROTO_VERSION)\"), halt(0)."



